<template>
	<view style="display: flex">
		<u-tabbar :value="activeTabName" :fixed="false" @change="changeTab" activeColor="#00aaff"
			inactiveColor="#7A7E83" :z-index="10">
			<u-tabbar-item v-for="(item, index) in tabbarList" :key="item.name" :text="item.text" :name="item.name"
				:icon="item.icon" />
		</u-tabbar>
	</view>
</template>
<script setup>
const { proxy } = getCurrentInstance();
const props = defineProps({
	activeTabName: {
		type: String,
		required: true,
		default: 'index',
	},
});
let tabbarList = [
	{
		pagePath: '/pages/material/index',
		text: '素材下载',
		icon: 'home',
		name: 'index',
	},
	{
		pagePath: '/pages/clockIn/index',
		text: '打卡',
		icon: 'photo',
		name: 'clockin',
	},
	{
		pagePath: '/pages/mine/index',
		text: '我的',
		icon: 'account',
		name: 'mine',
	},
];

function changeTab(name) {
	if (props.activeTabName === name) {
		return;
	}
	let path = tabbarList.filter((e) => e.name === name)[0].pagePath;
	// if (path == '/pages/clockIn/index') {
	// 	uni.reLaunch({
	// 		url: `${path}`,
	// 	});
	// } else {
	// }
	uni.reLaunch({
		url: path,
	});
}
</script>
<style lang="scss" scoped></style>
